<!DOCTYPE html>
<html>
<head>
    <title>录入住院信息--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css"/>
    <link rel="stylesheet" type="text/css" href="../Css/style.css"/>
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>


    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
        $(function () {
            $('#backid').click(function () {
                window.location.href = "index.html";
            });
        });

        function getInfo() {
            let id = $("input[name='hosregisterId']").val();
            $.ajax({
                type: "GET",
                url: "/registration/id/" + id, //RESTful风格的API定义
                data: "",
                success: function (vo) {
                    let obj = vo.obj;
                    let id = obj.id;
                    let name = obj.name;
                    let idCard = obj.idCard;
                    let medical = obj.medical;
                    let phone = obj.phone;
                    let selfPrice = obj.selfPrice;
                    if (selfPrice == 0)
                        $("#yes").attr('checked', true);
                    else
                        $("#no").attr('checked', true);
                    let sex = obj.sex;
                    if (sex == 0)
                        $("#nan").attr('checked', true);
                    else
                        $("#nv").attr('checked', true);
                    let age = obj.age;
                    let lookDoctor = obj.lookDoctor;
                    if (lookDoctor == 0)
                        $("#first").attr('checked', true);
                    else
                        $("#second").attr('checked', true);
                    let doctorName = obj.doctor.name;
                    let keShi = obj.doctor.keShi;
                    $("input[name='name']").val(name);
                    $("input[name='idCard']").val(idCard);
                    $("input[name='phone']").val(phone);
                    $("input[name='medical']").val(medical);
                    $("input[name='age']").val(age);
                    $("select[name='keShi']").val(keShi);
                    $("select[name='doctorName']").val(doctorName);
                }
            });
        }
    </script>
</head>
<body>
<form id="myForm" class="definewidth m20">
    <table class="table table-bordered table-hover definewidth m10">
        <tr>
            <td width="10%" class="tableleft">病历号</td>
            <td><input type="text" name="hosregisterId" value="" onchange="getInfo()"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">姓名</td>
            <td><input type="text" name="name" value="" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件类型</td>
            <td>身份证</td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">证件号</td>
            <td><input type="text" name="idCard" value="" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">社保号</td>
            <td><input type="text" name="medical" value="" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">联系电话</td>
            <td><input type="text" name="phone" value="" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">是否自费</td>
            <td><input type="radio" name="selfPrice" id="no" value="1"/>否&nbsp;&nbsp;&nbsp;<input type="radio"
                                                                                                  name="selfPrice"
                                                                                                  id="yes" value="0"/>是
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">性别</td>
            <td><input type="radio" name="sex" id="nan" value="0"/>男&nbsp;&nbsp;&nbsp;<input type="radio" name="sex"
                                                                                             id="nv" value="1"/>女
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">年龄</td>
            <td><input type="text" name="age" value="" readonly="readonly"/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">初复诊</td>
            <td><input type="radio" name="lookDoctor" id="first" value="0"/>初诊&nbsp;&nbsp;&nbsp;<input type="radio"
                                                                                                       name="lookDoctor"
                                                                                                       id="second"
                                                                                                       value="1"/>复诊
            </td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">所挂科室</td>
            <td><select name="keShi">
                <option value="急诊科">急诊科</option>
                <option value="骨科">骨科</option>
                <option value="血液科">血液科</option>
                <option value="外科">外科</option>
            </select></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">指定医生</td>
            <td><select name="doctorName">
                <option value="程俊">程俊</option>
                <option value="欧阳雨露">欧阳雨露</option>
                <option value="王博">王博</option>
                <option value="沈青川">沈青川</option>
            </select></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">护理</td>
            <td><input type="text" name="nursePeople" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">床位号</td>
            <td><input type="text" name="patBed" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">缴费押金</td>
            <td><input type="text" name="antecedent" value=""/></td>
        </tr>
        <tr>
            <td width="10%" class="tableleft">病情</td>
            <td><textarea id="illness" name="illness"></textarea></td>
        </tr>
        <tr>
            <td colspan="2">
                <center>
                    <button id="add" class="btn btn-primary" type="button">保存</button> &nbsp;&nbsp;<button
                        type="button" class="btn btn-success" name="backid" id="backid">返回列表
                </button>
                </center>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
<script>
    $(function () {
        //提交按钮的单击事件
        $("#add").click(function () {
            $.ajax({
                type: "POST",
                url: "/behospital/",
                data: $("#myForm").serialize(),
                dataType: "json",
                success: function (vo) {
                    if (vo.code == 200) {
                        window.location.href = "index.html";
                    } else {
                        alert("添加失败！" + vo.msg);
                    }
                }
            });
        });
    });
</script>